package cn.sangedon.review.common.util;

import cn.sangedon.review.common.constant.ResultStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private Integer status;

    private String msg;

    private Object data;

    public Result(Object data) {
        this(ResultStatus.SUCCESS, "成功", data);
    }

    public static ResultBuilder okBuilder() {
        return Result.builder().status(ResultStatus.SUCCESS).msg("成功");
    }

    public static Result ok() {
        return Result.builder().data(null).status(ResultStatus.SUCCESS).msg("成功").build();
    }

    public static Result error() {
        return Result.builder().status(ResultStatus.ERROR).msg("失败").data(null).build();
    }

    public static ResultBuilder errorBuilder() {
        return Result.builder().status(ResultStatus.ERROR).data(null).msg("失败");
    }
}
